/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

typedef struct ListNode ListNode;
ListNode* deleteNode(ListNode* head, int val)
{
    ListNode* phead = (ListNode*)malloc(sizeof(ListNode));
    ListNode* pre = phead;
    phead->next = head;

    ListNode* pcur = head;
    while (pcur)
    {
        if (pcur->val == val)
            pre->next = pcur->next;
        pre = pcur;
        pcur = pcur->next;
    }
    return phead->next;
}